package com.ruan.controller;

import com.ruan.common.Code;
import com.ruan.common.Result;
import com.ruan.pojo.Resign;
import com.ruan.service.ResignService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

@RestController
@RequestMapping("/resign")
@CrossOrigin
public class ResignController {

    @Resource
    private ResignService resignService;

    @GetMapping("/selectResignStatus")
    public Result selectResignStatus(String phone){

        return resignService.selectResignStatus(phone);

    }

    @DeleteMapping("/deleteResignByPhone")
    public Result deleteResignByPhone(String phone){
        try {
            resignService.deleteResignByPhone(phone);
            return new Result(Code.DELETE_OK,"撤销成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(Code.DELETE_ERR,"撤销失败！");
        }
    }

    @PostMapping("/appForResign")
    public Result appForResign(@RequestBody Resign resign){

        try {
            Result result = resignService.appForResign(resign);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(Code.SAVE_ERR,"提交失败！");
        }
    }
}
